﻿@using AdverseEventReportSystem.Model;
@{
    var adverseEventType = ViewBag.AdverseEventType as AdverseEventType;
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script>
        function save() {
            var id = $("#hdnTypeId").val();
            var name = $("#txtName").val();
            var remark = $("#txtRemark").val();

            if (IsEmpty(name)) {
                $.ligerDialog.error("名称不能为空");
                $("#txtName").focus();
                return;
            }

            var dialog = frameElement.dialog;
            $.ajax({
                url: "/AdverseEventType/Save",
                type: "post",
                data: {
                    Id: id,
                    Name: name,
                    Remark: remark
                },
                success: function (r) {
                    var r = $.parseJSON(r);
                    if (r.Result == 1) {
                        parent.$(".l-dialog-btn-inner").click();
                        dialog.close();
                    }
                    else if (r.Result == 0) {
                        $.ligerDialog.error(r.Body);
                    }
                    else {
                        $.ligerDialog.error("程序错误");
                    }
                }
            });
        }
        function closeDialog() {
            frameElement.dialog.close();//关闭dialog
        }
    </script>
</head>
<body>
    <div style="margin:10px 0px;">
        <table style="width:100%;">
            <tr>
                <td style="text-align:right; width:60px; height: 30px;line-height: 30px;">
                    名称：
                </td>
                <td>
                    <input type="text" id="txtName" class="l-text" maxlength="50" style="width:300px;" value="@(adverseEventType.Name)" /><font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:60px; height: 30px;line-height: 30px;">
                    备注：
                </td>
                <td style="padding-top: 5px;">
                    <textarea id="txtRemark" rows="7" class="l-textarea" maxlength="1000" style="padding:5px;width:290px;">@(adverseEventType.Remark)</textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center;padding-top:10px;">
                    <input id="btnSubmit" type="button" value="确定" class="l-button" onclick="save()" />&nbsp;&nbsp;&nbsp;
                    <input id="btnCancel" type="button" value="取消" class="l-button-cancel" onclick="closeDialog()" />
                </td>
            </tr>
        </table>
        <input type="hidden" id="hdnTypeId" value="@(adverseEventType.ID)" />
    </div>
</body>
</html>
